var app = angular.module('addTmApp',[]);
app.controller('addTmController',function($scope,$http){

    /*添加课程操作*/
    $scope.addTeacher = function () {

        $scope.tmdata = {tid:$scope.tid,
            password:$scope.password,
            tname:$scope.tname,
            professinalTitle:$scope.professinalTitle,
            contactWay:$scope.contactWay,
            instruction:$scope.instruction,
            role:$scope.role};
        $http({
            method: 'POST',
            url: 'teacher/addTeacherMsg.do',
            params: $scope.tmdata,
            headers: { 'Content-Type': 'application/x-www-form-urlencoded'}
        }).then(function successCallback(response) {
            console.log(response);
            $scope.isSuccess = response.data.isSuccess;
            if($scope.isSuccess==0){
                alert("添加成功");
                window.location.href = "/teachermsgUrl.do";
            }else if($scope.isSuccess==1)
                alert("添加出错，请检查内容填写内容是否为空，格式是否正确");
            else if($scope.isSuccess==2)
                alert("该教工号已经存在");
        }, function errorCallback(response) {
            console.log("获取失败！");
        });
    };

    $scope.backToTmList = function () {
        window.location.href = "/teachermsgUrl.do";
    };


});